Component({
  data: {
    active: 0,
    color: "#7A7E83",
    selectedColor: "#3cc51f",
    list: [
    {
      pagePath: "/pages/index/index",
      icon: "wap-home-o",
      text: "首页"
    },
    {
      pagePath: "/pages/category/category",
      icon: "apps-o",
      text: "分类"
    },
    {
      pagePath: "/pages/find/find",
      icon: "bulb-o",
      text: "发现"
    },
    {
      pagePath: "/pages/mine/mine",
      icon:"user-o",
      text: "我的"
    }
  
  ]
  },
  onLoad: function () {
    this.data.selected = 0
  },
  methods: {
    onChange(e) {
      this.setData({ active: e.detail });
      wx.switchTab({
        url: this.data.list[e.detail].pagePath
      });
   },
   init() {
    const page = getCurrentPages().pop();
    this.setData({
   　  active: this.data.list.findIndex(item => item.pagePath === `/${page.route}`)
    });
   },
   
  }
})